<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	window.onload = function (){
		var oTxt = document.getElementById('text1');
		var oBtn = document.getElementById('btn');

		oBtn.onclick = function (){
			var re = /^\w+@[0-9a-z]+\.[a-z]{2,4}$/; 		//+号并不是连接的意思，而是多个的意思

			if ( re.test(oTxt.value) ) {
				alert("you're right!");
			} else{
				alert("you're wrong!");
			};
		}
	}
	</script>
</head>
<body>
	<input id="text1" type="text" />
	<input id="btn" type="button" value="校验" />
</body>
</html>